/*
 * @Descripttion: 文件说明
 * @version: V1.0
 * @Author: GW
 * @Date: 2021-07-29 10:40:41
 * @LastEditors: GW
 * @LastEditTime: 2021-11-04 14:43:08
 */
import { axios } from "../utils/request";

const api = {
    TreeDataArea: "/system/area/getAreaTreeDataList",
    PageList: "/system/area/page",
    Save: "/system/area/save",
    DELETE: "/system/area/delete",
    AreaList: "/system/area/checkAreaList",
    SaveAreaList: "/system/area/saveAreaList",
    treeList: "/system/area/treeList"
};

/**
 * 获取地区树列表
 * parameter: {
 *     name: '',
 *     menuType: 1
 * }
 * @param parameter
 * @returns {*}
 */
export function TreeDataArea (parameter) {
    return axios({
        url: api.TreeDataArea,
        method: "get",
        params: parameter,
        timeout: 500000,
    });
}

/**
 * 获取地区列表
 */
export function PageList (parameter) {
    return axios({
        url: api.PageList,
        method: "get",
        params: parameter,
        timeout: 500000,
    });
}

export function treeList (data) {
    return axios({
        url: api.treeList,
        method: 'get',
        params: data,
        timeout: 500000
    });
}

/**
 * 新增/修改地区
 * @param {*} data
 */
export function saveSysArea (data) {
    console.log(data);
    return axios({
        url: api.Save,
        method: "post",
        data: data
    });
}

/**
 * 删除地区
 */
export function deleteSysArea (id) {
    console.log(id)
    return axios({
        url: api.DELETE,
        method: "DELETE",
        params: id
    });
}

/**
 * 获取授权地区
 */
export function AreaList (id) {
    return axios({
        url: api.AreaList,
        method: "get",
        params: id
    });
}

/**
 * 批量保存
 * @param {地区列表} data 
 */
export function saveAreaList (data) {
    return axios({
        url: api.SaveAreaList,
        timeout: 500000,
        isLoading: true,
        method: "post",
        data: data
    });
}